{layout name="public/layout" /}
{include file='yxnavbar'}
<style>
	.div_flex{
		display: flex !important;
	}
	.div_none{
		display: none; !important;
	}
	.shadow-box{
		width: 100%;
		height: 100%;
		position: fixed;
		top: 0;
		left: 0;
		background: rgba(0,0,0,0.5);
	}
	#alert_form {
		position: absolute;
		top: 10%;
		left: 30%;
		background: #fff;
		height: 80%;
		max-height: 700px;
	}
	.shadow-box .panel-body{
		max-height: 88%;
		overflow-y: auto;
	}
	.table td span{display:inline-block;margin-top:4px;}
	.table td input{margin-bottom:0;}
	.form-horizontal .form-group{
		margin-left: -15px;
		margin-right: -15px;
	}
	.form-group{
		margin-bottom: 30px;
		height: auto;
	}
	.demo{
		display:-webkit-box;
		display:-webkit-flex;
		display:-ms-flexbox;
		display:flex;
		-webkit-box-pack:justify;
		-webkit-justify-content:space-between;
		-ms-flex-pack:justify;
		justify-content:space-between;
	}

	.demo div{
		width:50%;
	}
</style>


<div class="main">
	<ul class="nav nav-tabs">
		<li  class="active"><a href="{php echo createWebUrl('exclusive_image',array('op'=>'display','themeid'=>$themeid));}">列表</a></li>
		<li><a href="{php echo createWebUrl('exclusive_image',array('op'=>'add','themeid' => $themeid));}">上传</a></li>
	</ul>
	<div class="panel panel-info">
		<div class="panel-heading">当前数量： {$page_total}</div>
		<div class="panel-body">
			<form id="myform" action="./index.php" method="get" class="form-horizontal" role="form">
				<input type="hidden" name="c" value="site" />
				<input type="hidden" name="a" value="entry" />
				<input type="hidden" name="m" value="{$_P['m']}" />
				<input type="hidden" name="do" value="{$do}" />
				<input type="hidden" name="op" value="{$op}" />
				<div class="form-group">
				<label class="col-xs-1 col-sm-1 col-md-1 control-label">机会数据</label>
					<div class="col-xs-11 col-sm-9 col-md-9">
						<div class="btn-group">
							<a href="#" class="btn btn-default">
								粉丝
								<span style="color: #ff0000">{$total_data['cnt']}</span>
							</a>
							<a href="#" class="btn btn-default">
								总机会
								<span style="color: #ff0000">{$total_data['all_chanece']}</span>
							</a>
							<a href="#" class="btn btn-default">
								已使用
								<span style="color: #ff0000">{$total_data['all_used_chance']}</span>
							</a>
							<a href="#" class="btn btn-default">
								未使用
								<span style="color: #ff0000">{$total_data['all_remaining_chance']}</span>
							</a>
						</div>
					</div>
			    </div>
				<div class="form-group col-xs-9 col-md-9 col-sm-12">
						<label class="col-xs-12 col-sm-3 col-md-1 control-label">条件筛选</label>
						<div class="col-sm-3 col-xs-4">
							<select id="company" name="company" class="col-sm-12">
								<option value="0">秀场公司</option>
								{loop $companylists $row}
							  	  <option value="{$row['id']}" {if $company == $row['id'] }selected="selected"{/if}>{$row['name']}</option>
								{/loop}
							</select>
						</div>
						<div class="col-sm-4 col-xs-4">
							<select  name="salesman" class="col-sm-12">
								<option value="0">所属销售</option>
								{loop $wlist $row}
								<option value="{$row['uid']}" {if $salesman == $row['uid'] } selected="selected"{/if}> {$row['username']}</option>
								{/loop}
							</select>

						</div>
						<div class="col-sm-4 col-xs-4">
							<select name="designer" class="col-sm-12">
								<option value="0">设计师</option>
								{loop $wlist $row}
							    	<option value="{$row['uid']}" {if $designer == $row['uid']}selected="selected"{/if}> {$row['username']}</option>
								{/loop}
							</select>
						</div>
				</div>

				<div class="form-group col-xs-9" >
					<label class="col-xs-12 col-sm-3 col-md-1 control-label">关键字</label>
					<div class="col-sm-4 col-xs-4 col-md-4">
						<input class="form-control" name="search_data" placeholder="输入专版名称" type="text" value="{$_P['search_data']}">
					</div>
					<div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
						<button class="btn btn-primary"><i class="fa fa-search"></i> 搜索</button>
						<input type="hidden" name="__token__" value="{$Request.token}"/>
					</div>
				</div>
			</form>
		</div>
	</div>

	<div class="tab-content">
		<div class="panel panel-default">
			<div class="panel-body table-responsive">
				<table class="table table-hover">
					<thead class="navbar-inner">
					<tr>
						<th style="width: 50px">ID</th>
						<th style="width: 100px">专版图片</th>
						<th style="width: 100px">专版名称</th>
						<th style="width: 120px">秀场公司</th>
						<th style="width: 50px">销售人员</th>
						<th style="width: 50px">设计师</th>
						<th style="width: 50px">状态</th>
						<th style="width: 100px">创建时间</th>
						<th style="width: 160px;text-align:right;">操作</th>
					</tr>
					</thead>
					<tbody>
					{loop $list $index $item}
						<tr>
							<td>{$item['id']}</td>
							<td>
								<img src="{php echo tomedia($item['img_url']);}" style="width: 40px;height: 40px;padding: 1px;">
							</td>
							<td>{$item['title']}</td>
							<td>{$item['company_name']}</td>
							<td>{$item['salesman_name']}</td>
							<td>{$item['designer_name']}</td>
							<td>
								{if $item['status'] == 0 }
								<span class="label label-primary">审核中</span>
								{elseif $item['status']==1}
								<span class="label label-success">审核成功</span>
								{elseif $item['status']==-1}
								<span class="label label-info">审核未通过</span>
								{elseif $item['status']==-2}
								<span class="label label-warning">已下架</span>
								{/if}
							</td>
							<td>{$item['create_time']}</td>
							<td class="str_center" style="text-align:right;">
								{if $item['status']==0}
							    	<a class="btn btn-primary btn-sm"  href="{php echo createWebUrl('exclusive_image', array('op' => 'audit','themeid'=>$themeid,'id'=>$item['id']));}" data-toggle="tooltip" data-placement="top">审核</a>
                                {/if}

								{if $item['status']==1}
									<a onclick="down(this)"
									   data-id = "{$item['id']}"
									   data-url="{php echo createWebUrl('exclusive_image', array('op' => 'down','themeid'=>$themeid));}"
									   title="下架"  class="btn btn-warning btn-sm"  data-toggle="tooltip" data-placement="top">下架
									</a>
								{/if}

								{if $item['status']==-2}
									<a onclick="up(this)"
									   data-id = "{$item['id']}"
									   data-url="{php echo createWebUrl('exclusive_image', array('op' => 'up','themeid'=>$themeid));}"
									   title="上架"  class="btn btn-info btn-sm"  data-toggle="tooltip" data-placement="top">上架
									</a>
								{/if}

								{if $item['status']==0||$item['status']==-1}
									<a onclick="changeOrDelItem(this)" data-action="del"
									   data-id = "{$item['id']}"
									   data-url="{php echo createWebUrl('exclusive_image', array('op' => 'delete','themeid'=>$themeid));}"
									   title="删除"  class="btn btn-danger btn-sm"  data-toggle="tooltip" data-placement="top">删除
									</a>
								{/if}

								<a class="btn btn-primary btn-sm"  href="{php echo createWebUrl('exclusive_image', array('op' => 'log','themeid'=>$themeid,'id'=>$item['id']));}" data-toggle="tooltip" data-placement="top">记录</a>
							</td>
						</tr>
					{/loop}
					</tbody>
				</table>
		    	</div>
	    	</div>
	   </div>
</div>
{$pager}

<script type="text/javascript">
	function changeOrDelItem(e) {
		let id = e.getAttribute("data-id");
		let postUrl =e.getAttribute("data-url");
		layer.msg('您确定删除此专版信息？',{
			btn:['确定','取消'],
			yes:function (index) {
				$.ajax({
					url:postUrl,
					dataType:'json',
					method:'post',
					data: {id:id},
					success:function (e) {
						let res = e.result;
						let status = res.status;
						let msg = res.msg;
						if (status!=1){
							layer.msg(msg);
						}else{
							layer.msg(msg);
						}
						parent.location.reload();
					},
					fail:function (err) {
						console.log(err)
					}
				});
				// parent.location.reload();
			}
		});
	}

	//上架
	function up(e){
		let id = e.getAttribute("data-id");
		let postUrl =e.getAttribute("data-url");
		layer.msg('确定上架专版信息？',{
			btn:['确定','取消'],
			yes:function (index) {
				$.ajax({
					url:postUrl,
					dataType:'json',
					method:'post',
					data: {id:id},
					success:function (e) {
						let res = e.result;
						let status = res.status;
						let msg = res.msg;
						if (status!=1){
							layer.msg(msg);
						}else{
							layer.msg(msg);
						}
						parent.location.reload();
					},
					fail:function (err) {
						console.log(err)
					}
				});
				// parent.location.reload();
			}
		});
	}
	//下架
	function down(e){
		let id = e.getAttribute("data-id");
		let postUrl =e.getAttribute("data-url");
		layer.msg('确定下架专版信息？',{
			btn:['确定','取消'],
			yes:function (index) {
				$.ajax({
					url:postUrl,
					dataType:'json',
					method:'post',
					data: {id:id},
					success:function (e) {
						let res = e.result;
						let status = res.status;
						let msg = res.msg;
						if (status!=1){
							layer.msg(msg);
						}else{
							layer.msg(msg);
						}
						parent.location.reload();
					},
					fail:function (err) {
						console.log(err)
					}
				});
				// parent.location.reload();
			}
		});
	}

</script>